# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=acpid
pkgver=2.0.33
pkgrel=2
pkgdesc="The ACPI Daemon (acpid) With Netlink Support"
url="https://sourceforge.net/projects/acpid2/"
arch="all"
license="GPL-2.0-or-later"
# zzz is used in provided handler.sh; it's not required by acpid itself and
# it's only useful for notebooks/desktops/alike, but we can assume that this
# acpid package will be mostly used on such devices (others will just use
# busybox acpid which is installed by default).
depends="zzz"
makedepends="linux-headers"
install="$pkgname.post-deinstall"
subpackages="$pkgname-doc $pkgname-openrc"
source="https://downloads.sourceforge.net/sourceforge/acpid2/acpid-$pkgver.tar.xz
	handler.sh
	power-supply-ac
	lid-closed
	anything
	$pkgname.initd
	$pkgname.confd
	"
options="!check"  # no tests provided

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/ \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--docdir=/usr/share/doc \
		--localstatedir=/var
	make
}

package() {
	make install DESTDIR="$pkgdir"

	cd "$pkgdir"

	install -D -m 755 "$srcdir"/handler.sh etc/acpi/handler.sh
	install -D -m 644 "$srcdir"/anything etc/acpi/events/anything
	install -D -m 755 "$srcdir"/power-supply-ac "$srcdir"/lid-closed -t usr/share/acpid/

	install -D -m 755 "$srcdir"/$pkgname.initd etc/init.d/$pkgname
	install -D -m 644 "$srcdir"/$pkgname.confd etc/conf.d/$pkgname
}

openrc() {
	default_openrc
	replaces="busybox-initscripts"  # overwrites /etc/init.d/acpid
}

sha512sums="
491a58c62fcad44dc57cbd9294437fbc215c2ec99a030286601cd1956ea504e723e61b11b315983073d66aace1997bc40e6421475f6073298f60b8dcda2add75  acpid-2.0.33.tar.xz
41b206253f49ae587ff8436c307b453a88e0751fbd3c8e75a3af27b92113b3496c9fb59cb7daed06339005ef70735d8d1eb0c0c6c42b52b700992dcb28217757  handler.sh
daf2510f202377a4db9b52448e4805bc4468c66f507cd4e676dc589306b716043c653ff18b697a4c37e5a005123a64a0278f3e4980504d98dd42ac9e95a3443f  power-supply-ac
f6df3e75198e779826c187038804ba80e7a445567342ac912ff4e5d894ce936fb9347146c302c7d7c9bbc8b3a0e47aeee9d23a4b297ee37e3938b7310a1b5ad9  lid-closed
2e04e5c8a428bfc653b4d56f5a2ff4472169a094ed9eee4b02ea88c755848e4803a0edeb054e152516ee50cb67c8c2be2c43e2e9db9dc80b7fcf218b8907ef6c  anything
c647112006486abb469fdb60c2a91699e6922dac8b09642fa70d4341c9029748f99539d5befc8951adf57a6b382cf5a65adfd208bc2f19cab39b680120504e61  acpid.initd
b8f62dc7d5a2d1338936af79b3e7165cc1c652be0be9e7f8eb00d964c1c1ef91767f16e8662eaa77920d914b966ae208c8480e44cb2dca0de4bfed01f302a089  acpid.confd
"
